import java.util.Random;
import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        //双色球彩票系统
        //1 生成中奖号码
        int[] arr = creativeArr();

        //打印出中奖号码
        System.out.println("**************");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        System.out.println("****************");

        //2 用户输入彩票号码
        int[] InputNumber = UserInputArr();

        //判断用户是否中奖
        int RedNumber = 0;
        int BlueNumber = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            //判断红球是否中奖
            int temp = InputNumber[i];
            for (int j = 0; j < arr.length; j++) {
                if (temp == arr[j]) {
                    RedNumber++;
                    break;
                }
            }
        }

        //判断篮球是否中奖
        int BlueCount = InputNumber[InputNumber.length - 1];
        if (BlueCount == arr[arr.length - 1]) {
            BlueNumber++;
        }

        //根据红篮球的个数判断中的是几等奖
        if (RedNumber == 6 && BlueNumber == 1) {
            System.out.println("恭喜你，中奖1000万");
        } else if (RedNumber == 6 && BlueNumber == 0) {
            System.out.println("恭喜你，中奖500万");
        } else if (RedNumber == 5 && BlueNumber == 1) {
            System.out.println("恭喜你，中奖3000");
        } else if( (RedNumber == 5 && BlueNumber == 0)||(RedNumber == 4 && BlueNumber == 1) ){
            System.out.println("恭喜你，中奖200");
        } else if ((RedNumber == 4 && BlueNumber == 0) ||(RedNumber == 3 && BlueNumber == 1)) {
            System.out.println("恭喜你，中奖10");
        } else if ((RedNumber == 2 && BlueNumber == 1) ||(RedNumber == 1 && BlueNumber == 1)||(RedNumber == 0 && BlueNumber == 1)){
            System.out.println("恭喜你，中奖5");
        } else {
            System.out.println("谢谢参与");
        }

    }

    //接受用户输入的数字
    public static int[] UserInputArr() {
        int[] UserInputnumber = new int[7];
        //键盘输入红球的
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 6; ) {
            System.out.println("请输入第" + (i + 1) + "个红球号码");
            int rednumber = sc.nextInt();
             if (rednumber >= 1 && rednumber <= 33){
                //输入的数字是否已经存在
                boolean flag = contions(UserInputnumber, rednumber);
                if (!flag) {
                    //输入的数字不存在
                    //可以添加
                    UserInputnumber[i] = rednumber;
                    i++;
                } else {
                    System.out.println("当前号码已经存在，请重新输入");
                }
            } else {
                //范围不对
                System.out.println("您输入的数字超出范围，请重新输入");
            }
        }
        //键盘输入篮球的号码
        System.out.println("请输入篮球号码");
        int BlueNumber = sc.nextInt();
        while (true) {
            if (BlueNumber >= 1 && BlueNumber <= 16) {
                UserInputnumber[UserInputnumber.length - 1] = BlueNumber;
                break;
            } else {
                System.out.println("当前号码超出范围，重新输入");
            }
        }
        return UserInputnumber;
    }

    public static int[] creativeArr() {
        //6个红球1个篮球用于抽奖
        //生成随机数 放入数组
        int[] arr = new int[7];
        Random r = new Random();
        for (int i = 0; i <= 6; ) {
            //获取红球的号码
            int Rednumber = r.nextInt(33) + 1; //范围1到33
            boolean flag = contions(arr, Rednumber);
            if (!flag) {
                arr[i] = Rednumber;
                i++;
            }
        }

        //获取篮球的号码
        int Bluenumber = r.nextInt(16) + 1;
        arr[arr.length - 1] = Bluenumber;
        return arr;
    }

    //判断生成的随机数是否在数组里面
    public static boolean contions(int[] arr, int Rednumber) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == Rednumber) {
                return true;
            }
        }
        return false;
    }
}
